/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package wumpusworld;

import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JOptionPane;

/**
 *
 * @author Jedrek
 */
public class SmalllCanvas extends Canvas{

    MyCanvas mainCanvas = null;
    WumpusEngine wumpusEngine;

    public SmalllCanvas(MyCanvas mainCanvas, WumpusEngine wumpusEngine){
        this.mainCanvas = mainCanvas;
        this.wumpusEngine = wumpusEngine;
    }
    /**
     * repainting
     * @param g
     */
    @Override
    public void update(Graphics g){
        paint(g);
    }

    /**
     * painting map
     * @param g
     */
    @Override
    public void paint(Graphics g){
        if( mainCanvas != null && wumpusEngine != null )
            mainCanvas.drawMarks((Graphics2D)g, wumpusEngine.getAgentCellState(), 0, 0, getWidth(), getHeight());
    }

    public void setCanvas(MyCanvas canvas){
        this.mainCanvas = canvas;
    }

    public void setEngine(WumpusEngine engine){
        this.wumpusEngine = engine;
    }
}
